﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Reader
{
    public partial class Zhuce : Form
    {
        public Zhuce()
        {
            InitializeComponent();
        }

        private void btzhuce_Click(object sender, EventArgs e)
        {
            string zhanghao = txtzhanghao.Text;
            string mima = txtmima.Text;
            string name = txtname.Text;
            string xingbie = txtxingbie.Text;
            DateTime date = Convert.ToDateTime(dateTime.Text);
            string diqu = txtdiqu.Text;
            if (string.IsNullOrEmpty(zhanghao) || string.IsNullOrEmpty(mima) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(xingbie)  || string.IsNullOrEmpty(diqu))//进行非空判断
            {
                MessageBox.Show("数据填写不完整");
                return;
            }
            string sql = string.Format("insert into Yonghu(Zhanghao,Mima, Name, Xingbie, Shengri, Diqu) values('{0}','{1}','{2}','{3}','{4}','{5}')", zhanghao,mima, name, xingbie, date, diqu);
            if (DBHelper.ExecuteNonQuery(sql))//添加数据
            {
                MessageBox.Show("添加用户信息成功");
                Hide();
            }
            else
            {
                MessageBox.Show("添加数据失败，请联系管理员");

            }
        }

        private void btquxiao_Click(object sender, EventArgs e)
        {
            Hide();
        }
    }
}
